var t = getApp();

Page({
    data: {
        Num: "",
        id: "",
        Text: "",
        result: "1"
    },
    onLoad: function(t) {
        this.setData({
            id: t.id
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    publish: function() {
        if (t._isTextEmpty(this.data.Num) || isNaN(this.data.Num)) wx.showToast({
            title: "请输入发放数量，必须是整数",
            icon: "none"
        }); else if (isNaN(this.data.result) || !t._isTextEmpty(this.data.Text)) {
            var o = {
                id: this.data.id,
                send_total: this.data.Num,
                sendtype: this.data.result,
                send_memberids: this.data.Text
            }, e = t.getNetAddresss("plugin.store-cashier.frontend.store.center.coupon.send");
            t._postNetWork({
                url: e,
                data: o,
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? (wx.showToast({
                        title: "发放成功",
                        icon: "none"
                    }), setTimeout(function() {
                        wx.navigateTo({
                            url: "/packageB/member/commodity_coupon/commodity_coupon/commodity_coupon"
                        });
                    }, 2e3)) : 0 === o.result && (o.data.url ? wx.navigateTo({
                        url: o.data.url
                    }) : wx.showToast({
                        title: o.msg,
                        icon: "none"
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            title: "请输入会员ID",
            icon: "none"
        });
    },
    conFim: function(t) {
        this.setData({
            Text: t.detail.value
        });
    },
    clearSrcoll: function(t) {
        this.setData({
            Num: t.detail.value
        });
    }
});